package edu.pku.sei.gefcommon.common.resourceManager;

import java.util.HashMap;
import java.util.Iterator;

public class ResourceGroupManager {
	public static ResourceGroupManager SINGLETON = new ResourceGroupManager();
	private HashMap<Object,ResourceManager> managers;
	public ResourceGroupManager(){
		managers = new HashMap<Object,ResourceManager>();
		addManager(COLOR_RESOURCE,new ColorManager());
	}
	
	private void addManager(Object id,ResourceManager m){
		managers.put(id,m);
	}
	public void dispose(){
		Iterator<ResourceManager> it = managers.values().iterator();
		while(it.hasNext()){
			it.next().dispose();
		}
	}
	public ResourceManager getManager(Object id){
		return managers.get(id);
	}	
	
	final static public String COLOR_RESOURCE = "COLOR_RESOURCE";
	static public org.eclipse.swt.graphics.Color getSWTColor(int r,int g,int b){
		ColorManager m = (ColorManager)SINGLETON.getManager(COLOR_RESOURCE);
		if(m==null) return null;
		else return m.getSWTColor(r, g, b);
	}
	static public org.eclipse.swt.graphics.Color getSWTColor(Color c){
		ColorManager m = (ColorManager)SINGLETON.getManager(COLOR_RESOURCE);
		if(m==null) return null;
		else return m.getSWTColor(c);
	}
}
